#include <bits/stdc++.h>

using namespace std;

int main()
{
	freopen("arena.in","r",stdin);
	freopen("arena.out","w",stdout);
	int n, m; cin >> n >> m;
	for(int i = 1;i <= n;i ++ ) {int a; cin >> a;}
	for(int i = 1;i <= m;i ++ ) {int c; cin >> c;}
	int k = 1;
	for(;pow(2, k) < n;k ++ );
	for(int i = 1;i <= k;i ++ ){
		string s; cin >> s;
	}
	int T; cin >> T;
	while(T -- ) {	
		cout << 1 << endl;
	}
}
